<?php

class  Somi_Models_Inventar extends Zend_Db_Table_Abstract 
{
	protected $_name='inventar';
	protected $_primary = 'inventar_id';
	#protected $_rowClass = 'user';
	protected $_sequence  = true;
	#protected $_dependentTables = array('email');
	
	
	public function fetchBySearch($query)
	{
		$select=$this->select();
		$select->from('inventar',array('id'=>'inventar_id','name'=>'beschreibung'));
		$select->where('beschreibung LIKE?',strtolower($query).'%');
		return $this->fetchAll($select);
	}
	
	public function getKategori(){
    	
   		 # Starte den Datenbank
    	$db= Zend_Registry::get('db');
    	# die Beschreibungen(kopf zeile) von tabelle Inventar laden
		$temp = $db->describeTable('inventar');
		# Lade die datentype (Enum)  
		$temp_enum=$temp['kategori']['DATA_TYPE'];
		# Explode die Datatype 
		$temp=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$temp_enum));
		
    	return $temp;
    	
    }
    
	public function getVertragsart(){
    	
   		 # Starte den Datenbank
    	$db= Zend_Registry::get('db');
    	# die Beschreibungen(kopf zeile) von tabelle Inventar laden
		$temp = $db->describeTable('inventar');
		# Lade die datentype (Enum)  
		$temp_enum=$temp['vertragsart']['DATA_TYPE'];
		# Explode die Datatype 
		$temp=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$temp_enum));
		
    	return $temp;
    	
    }
    
	public function getKostenstelle(){
    	
   		 # Starte den Datenbank
    	$db= Zend_Registry::get('db');
    	# die Beschreibungen(kopf zeile) von tabelle Inventar laden
		$temp = $db->describeTable('inventar');
		# Lade die datentype (Enum)  
		$temp_enum=$temp['kostenstelle']['DATA_TYPE'];
		# Explode die Datatype 
		$temp=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$temp_enum));
		
    	return $temp;
    	
    }

	public function getInventarByid($id){
		
    	$inventar=$this->fetchRow('inventar_id='.$id);
    	return $inventar;
    }
	
}

?>